local VERSION = "03";
local nkLibSocial = LibStub:NewLibrary("nkLibSocial", VERSION);

if not nkLibSocial then
    return	-- already loaded and no upgrade necessary
end


-- Checks if a player is part of the current group or raid and if so returns ID

nkLibSocial.getGrpRaidUnitID = function (playername)
	
	local unitID = nil;

	if (playername == UnitName("player")) then 
		unitID = "player";
	elseif (UnitInRaid("player")) then
		for b=1,36 do
			if (UnitExists("raid"..b)) then
				if (string.lower(UnitName("raid"..b)) == string.lower(playername)) then
					unitID = "raid"..b;
					break;
				end
			end;
		end;
	elseif(UnitExists("party1")) then
		for a=1,GetNumPartyMembers()-1 do
			if (UnitExists("party"..a)) then
				if (string.lower(UnitName("party"..a)) == string.lower(playername)) then
					unitID = "party"..a;
					break;
				end
			end;
		end;
	end;
	
	return unitID;
end;

-- Checks if a player is part of the current group or raid

nkLibSocial.checkPlayerInGroupOrRaid = function (playername, showmsg)
	
	local unitID = nkLibSocial.getGrpRaidUnitID (playername); 
	
	if (unitID == nil and showmsg == true) then
		Sol.io.Printf (nkPartyQuest.AddonName ..": |cffFF0000" .. playername .. " is not in your party or raid|r");
--	elseif (unitID ~= nil) then
--		Sol.io.Printf (nkPartyQuest.AddonName ..": |cffFF0000" .. playername .. " IS in your party or raid|r");
	end;

	return unitID;
end;